package com.heart.admin.controller;

import com.heart.common.constant.AppCode;
import com.heart.common.constant.AppConstant;
import com.heart.dao.dto.RequestResult;
import com.heart.dao.entity.Question;
import com.heart.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/question")
public class QuestionController {

    @Autowired
    private QuestionService questionService;
    @PostMapping("/getDashboardNumber")
    public RequestResult getDashboardNumber(String type){
        return new RequestResult(AppCode.SUCCESS,questionService.getDashboardNumber(type), AppConstant.SUCCESS);
    }

    @PostMapping("/getDashboardListNumber")
    public RequestResult getDashboardListNumber(){
        return new RequestResult(AppCode.SUCCESS,questionService.getDashboardListNumber(), AppConstant.SUCCESS);
    }

    @PostMapping("/getQuestionListByUserCode")
    public RequestResult getQuestionListByUserCode(String userCode){
        return new RequestResult(AppCode.SUCCESS,questionService.getQuestionListByUserCode(userCode), AppConstant.SUCCESS);
    }

    @PostMapping("/getQuestionAndDetailById")
    public RequestResult getQuestionAndDetailById(Integer questionId){
        return new RequestResult(AppCode.SUCCESS,questionService.getQuestionAndDetailById(questionId), AppConstant.SUCCESS);
    }

    @PostMapping("/getQuestionById")
    public RequestResult getQuestionById(Integer questionId){
        return new RequestResult(AppCode.SUCCESS,questionService.getQuestionById(questionId), AppConstant.SUCCESS);
    }


    @PostMapping("/getQuestionDetailListByQuestionId")
    public RequestResult getQuestionDetailListByQuestionId(String questionId){
        return new RequestResult(AppCode.SUCCESS,questionService.getQuestionDetailListByQuestionId(questionId), AppConstant.SUCCESS);
    }

    @PostMapping("/updateQuestion")
    public  RequestResult updateQuestion(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.updateQuestion(question), AppConstant.SUCCESS);
    }

    @PostMapping("/updateQuestionSetting")
    public  RequestResult updateQuestionSetting(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.updateQuestionSetting(question), AppConstant.SUCCESS);
    }

    @PostMapping("/publishQuestion")
    public  RequestResult publishQuestion(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.publishQuestion(question), AppConstant.SUCCESS);
    }
    @PostMapping("/deleteQuestion")
    public  RequestResult deleteQuestion(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.deleteQuestion(question), AppConstant.SUCCESS);
    }
    @PostMapping("/completeDeleteQuestion")
    public  RequestResult completeDeleteQuestion(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.completeDeleteQuestion(question), AppConstant.SUCCESS);
    }
    @PostMapping("/saveQuestion")
    public RequestResult saveQuestion(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.saveQuestion(question), AppConstant.SUCCESS);
    }
    @PostMapping("/copyQuestion")
    public RequestResult copyQuestion(@RequestBody Question question){
        return new RequestResult(AppCode.SUCCESS, questionService.copyQuestion(question), AppConstant.SUCCESS);
    }
    @PostMapping("/validateQuestionLimit")
    public RequestResult validateQuestionLimit(HttpServletRequest request, String questionId){
        return new RequestResult(AppCode.SUCCESS, questionService.validateQuestionLimit(request,questionId), AppConstant.SUCCESS);
    }

}
